package com.iwhalecloud.citybrain.flow.platform.manager.infrastructure.repository;

import com.iwhalecloud.citybrain.flow.platform.manager.domain.model.FlowFormExternalInstanceDO;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.repository.FlowFormExternalRepository;
import com.iwhalecloud.citybrain.flow.platform.manager.infrastructure.entities.FlowFormExternalInfoDO;
import com.iwhalecloud.citybrain.flow.platform.manager.infrastructure.mapper.FlowFormExternalInfoDAO;
import com.iwhalecloud.citybrain.flow.platform.manager.infrastructure.mapper.FlowFormExternalInstanceDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author: liyang
 * @date: 2021/10/14 21:27
 */
@Service
public class FlowFormExternalRepositoryImpl implements FlowFormExternalRepository {

    @Autowired
    private FlowFormExternalInstanceDAO flowFormExternalInstanceDAO;

    @Autowired
    private FlowFormExternalInfoDAO flowFormExternalInfoDAO;

    @Override
    public void save(FlowFormExternalInstanceDO flowFormExternalInstanceDO) {
        flowFormExternalInstanceDAO.insertExternalInstance(flowFormExternalInstanceDO);
    }

    @Override
    public boolean isExternalForm(String formId) {
        FlowFormExternalInfoDO flowFormExternalInfoDO = flowFormExternalInfoDAO.selectByFormId(formId);
        return Objects.nonNull(flowFormExternalInfoDO);
    }
}
